<template>
  <div>
    <h1>互动留言板</h1>
    <div class="message-container">

      <div class="message-item" v-for="item in commentList" :key="item.id">
        <div class="message-header">
          <div class="message-name">{{item.nickname}}</div>
          <div class="message-time">{{$fromatDateAll(item.created_at)}}</div>
        </div>
        <div class="message-content">留言内容:{{item.content}}</div>

        <div class="reply-container" v-if="item.replies && item.replies[0]">
          <div class="reply-content" >管理员回复内容:{{item.replies[0].content ? item.replies[0].content:'暂无回复' }}</div>
          <div class="reply-time" >{{ $fromatDateAll(item.replies[0].created_at) }}</div>

        </div>
      </div>
    </div>
    <div class="pagnation">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="1000">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { getComment } from '@/api/article'
export default {
  name: 'HotelSystemUserComment',

  data () {
    return {
      commentList: [], // 留言列表
      replies: []
    }
  },

  mounted () {
    this.initComment()
  },

  methods: {
    async initComment () {
      const { data: res } = await getComment()
      this.commentList = res.data
      // console.log(res)
    }
  }
}
</script>

<style lang="less" scoped>
body {
  font-family: Arial, sans-serif;
  background-color: #f1f1f1;
}

h1 {
  text-align: center;
  margin-top: 50px;
  margin-bottom: 30px;
}

.message-container {
  width: 70%;
  margin: 0 auto;
  background-color: #fff;
  box-shadow: 0 0 5px #ccc;
  padding: 20px;
  margin-bottom: 30px;
}

.message-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #ccc;
}

.message-item:last-child {
  border-bottom: none;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.message-name {
  font-size: 18px;
  font-weight: bold;
}

.message-time {
  font-size: 12px;
  color: #999;
}

.message-content {
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 10px;
}

.reply-container {
  padding: 10px;
  background-color: #f6f6f6;
}

.reply-content {
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 5px;
}

.reply-time {
  font-size: 12px;
  color: #999;
}

.reply-container:not(:last-child) {
  margin-bottom: 10px;
}
.pagnation {
  display: flex;
  justify-content: center;
}
</style>
